package br.ufal.tci.nexos.arcolive.persistence;

import br.ufal.tci.nexos.arcolive.participant.ArCoLIVEParticipant;



public interface ArCoLIVEPersistence {
	
	public boolean connect();
	
	public boolean isConnected();
	
	/* Command */
	
	public GenericResultSet getAllCommands();
	
	public GenericResultSet getAllCommandsOfService(int serviceId, boolean justAvailable);
	
	public GenericResultSet getOneCommand(int commandId);
	
	public GenericResultSet getParametersCommand(int commandId);
	
	public boolean insertCommand(String name, String description, int implementationId, String implementationClasspath);
	
	public boolean updateCommand(int commandId, String name, String description, int implementationId, String implementationClasspath);
	
	public boolean removeCommand(int commandId);
	
	/* Country */
	
	public GenericResultSet getAllCountries();
	
	public GenericResultSet getOneCountry(int countryId);
	
	/* Participant */
	
	public GenericResultSet getAllParticipants();
	
	public GenericResultSet getOneParticipant(int participantId);
	
	public GenericResultSet getOneParticipant(String username);
	
	public boolean insertParticipant(String fullname, String email, String username, String password, int participantGroupIds[], String location, String city, String state, int countryId, boolean enabled, String msnMessager, String yahooMessager, String aolMessager);
	
	public boolean changeParticipantStatus(int participantId, boolean enabled);
	
	public boolean updateParticipant(int participantId, String fullname, String email, String username, String password, int participantGroupIds[], String location, String city, String state, int countryId, String msnMessager, String yahooMessager, String aolMessager);
	
	public boolean removeParticipant(int participantId);
	
	/* ParticipantGroup */
	
	public GenericResultSet getAllParticipantGroups();
	
	public GenericResultSet getOneParticipantGroup(int groupId);
	
	public boolean authenticateUser(String username, String password);
	
	public boolean insertParticipantGroup(String name, String description, int instanceId);
	
	public boolean updateParticipantGroup(int groupId, String name, String description, int instanceId);
	
	public boolean removeParticipantGroup(int groupId);
	
	public boolean insertParticipantInGroup(int groupId, int participantId);
	
	public boolean isParticipantInGroup(int groupId, int participantId);
	
	/* Server */
	
	public GenericResultSet getAllServers();
	
	public GenericResultSet getOneServer(int serverId);
	
	public boolean insertServer(String serverName, String serverIP, int port);
	
	public boolean updateServer(int serverId, String serverName, String serverIP);
	
	public boolean removeServer(int serverId);
	
	/* Service */
	
	public GenericResultSet getAllServices();
	
	public GenericResultSet getAvailableService();
	
	public GenericResultSet getOneService(int serviceId);
	
	public boolean insertService(String name, String description, String implementationClasspath);
	
	public boolean updateService(int serviceId, String name, String description, String implementationClasspath);
	
	public boolean removeService(int serviceId);
	
	public GenericResultSet getServiceParameters(int serviceId);
	
	/* Service Instance */
	
	public GenericResultSet getAllServiceInstance(int serviceId, boolean justAvailable);
	
	public GenericResultSet getOneServiceInstance(int serviceInstanceId);
	
	public boolean insertServiceInstance(String name, String description, boolean enabled, int maxConnection, int serviceId, int managerId);
	
	public boolean updateServiceInstance(int serviceInstanceId, String name, String description, boolean enabled, int maxConnection, int serviceId, int managerId);
	
	public boolean removeServiceInstance(int serviceInstanceId);
	
	public String getInstanceImplementationClass(int instanceId);
	
	/* Servic Instance parameters */
	
	public GenericResultSet getAllServiceInstanceParameter(int instanceId);
	
	public GenericResultSet getOneServiceInstanceParameter(int instanceId, int serviceParameterId);
	
	public GenericResultSet getParameter(String serviceParameterName);
	
	/* Permission */
	
	public GenericResultSet getParticipantPermission(int participantId, int serviceId, int serviceInstanceId);
	
	public boolean isCommandPermitted(int commandId, ArCoLIVEParticipant participant, int serviceId, int serviceInstanceId);
	
	public boolean isCommandPermitted(int commandId, ArCoLIVEParticipant participant, int serviceId);
	
	public boolean isCommandPermitted(int commandId, ArCoLIVEParticipant participant);
		
	public boolean verifyCommandPermission(int commandId, int participantId, int serviceId, int serviceInstanceId);
	
	public boolean grantParticipantPermission(int commandId, int serviceId, int serviceInstanceId, int objectId, String object);
	
	public boolean revokeParticipantPermission(int commandId, int serviceId, int serviceInstanceId, int objectId, String object, boolean hard);
	
}

